package de.fmannan.wildit.service;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;
import android.widget.Toast;

public class AlarmReceiver extends BroadcastReceiver {

	/**
	 * Extracts a property called "ID" from the intent. With this ID the
	 * Receiver searches the database for matching alarm settings. If it finds
	 * them, it'll check the following things: Is the alarm currently enabled?
	 * If No, the alarm is cancelled altogether. If the alarm is enabled, the
	 * following things are checked: Does this alarm specify a start and end
	 * time? Does it have an interval? Is the current time between the start and
	 * end time or beyond? If the current time is not within the range of the
	 * given start and end time, the alarm is not played but instead
	 * rescheduled.
	 */
	@Override
	public void onReceive(Context context, Intent intent) {

		Vibrator alarm = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);

    	alarm.vibrate(new long [] {2000, 3000, 5000}, 2);

		Toast.makeText(context, "Perform a reality check", Toast.LENGTH_LONG)
				.show();		

		/*
		manager.cancel(PendingIntent.getBroadcast(context, 100, intent, 0));
		Toast.makeText(context, "Canceled alarm", Toast.LENGTH_LONG)
		.show();		
*/
	}

}
